{block name=location_summary}
{* Define the function *}
{function name=render_locations }
  {foreach $items as $d}
		  <div class="clear"></div>
		  <div class="col-md-12 location-centered">
		  	<hr class="blue-border">
		  	<h2>{$state}</h2>
		  </div>
		  {assign var='hasitems' value=1}
		  {break}
  {/foreach} 
  
  {if $hasitems eq 1}
	  {foreach $items as $d}
	       <div class="col-sm-6 location-summary loc" latitude="{$d.location_latitude}" longitude="{$d.location_longitude}" title="{$d.location_name}" pin="{$d.location_pin}">
					<div class="location-centered">
						<div class="new-location">{if $d.location_flag eq 1}<span>New location</span>{/if}</div>
						<span class="location-suburb">{$d.location_name|upper}</span><br>
						  {$d.location_street}<br>
						  {$d.location_suburb}<br>
						{$d.location_state} {$d.location_postcode}<br />  
						<a href="https://www.google.com/maps/dir/Current+Location/{$d.location_latitude},{$d.location_longitude}" target="_blank">Get directions</a><br />
						{if $d.location_url}<a href="{externallink data=$d.location_url}" target="_blank">{$d.location_url|replace:"https://":""|replace:"http://":""}</a>{/if}<br />
						  <a class="enrolnow" href="/enrol/search?id={$d.location_object_id}&location={$d.location_suburb}%2C+{$d.location_state}%2C+{$d.location_postcode}">View classes</a>
					</div>
				</div>
	  {/foreach}
  {/if}  
{/function}

   	<div class="col-md-12" id="reshead">
    {if $q}
    	{count($locations)} location{if count($locations) gt 1}s{/if} found for <b>{$q}</b>
    {elseif $coordinates}
    	{count($locations)} location{if count($locations) gt 1}s{/if} near you. <a href="javascript:void(0)" onclick="$('#query').val(''); findStore();">View all locations</a>
    {/if}
    </div>
    {call name=render_locations items=$locations}

    
{/block}